﻿<%@ Page Title="" Language="C#" MasterPageFile="~/BackEnd.master" AutoEventWireup="true" CodeFile="~/Code/single_job.aspx.cs" Inherits="single_job" %>

<asp:Content ID="Content1" ContentPlaceHolderID="cph_Main" Runat="Server">
    <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" 
        CellPadding="4" DataKeyNames="Job_ID" DataSourceID="specific_job" 
        ForeColor="#333333" GridLines="None" Height="50px" Width="409px" 
        onpageindexchanging="DetailsView1_PageIndexChanging">
        <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
        <CommandRowStyle BackColor="#E2DED6" Font-Bold="True" />
        <EditRowStyle BackColor="#999999" />
        <FieldHeaderStyle BackColor="#E9ECF1" Font-Bold="True" />
        <Fields>
            <asp:BoundField DataField="Incident_ID" HeaderText="Incident_ID" 
                ReadOnly="True" SortExpression="Incident_ID" />
            <asp:BoundField DataField="Job_ID" HeaderText="Job_ID" InsertVisible="False" 
                ReadOnly="True" SortExpression="Job_ID" />
            <asp:BoundField DataField="Description" HeaderText="Description" 
                ReadOnly="True" SortExpression="Description" />
            <asp:BoundField DataField="Date Created" HeaderText="Date Created" 
                ReadOnly="True" SortExpression="Date Created" />
            <asp:BoundField DataField="Assigned Team" HeaderText="Assigned Team" 
                ReadOnly="True" SortExpression="Assigned Team" />
            <asp:CheckBoxField DataField="Job Completed?" HeaderText="Job Completed?" 
                SortExpression="Job Completed?" />
            <asp:TemplateField HeaderText="Date Resolved" SortExpression="Date Resolved">
                <EditItemTemplate>
                    <asp:Calendar ID="Calendar1" runat="server" SelectedDate=<%# DateTime.Now %> 
                        Enabled="False" VisibleDate="<%# DateTime.Now %>"></asp:Calendar>
                    You cannot change this value; it submits as Today.
                </EditItemTemplate>
                <InsertItemTemplate>
                    <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("[Date Resolved]") %>'></asp:TextBox>
                </InsertItemTemplate>
            </asp:TemplateField>
        </Fields>
        <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
        <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
        <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
        <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
    </asp:DetailsView>
    <asp:Button ID="resolve_btn" runat="server" onclick="resolve_btn_Click" 
        Text="Resolve this Job?" />
    <br />
    <asp:AccessDataSource ID="specific_job" runat="server" 
        DataFile="~/App_Data/Database.accdb" 
        DeleteCommand="DELETE FROM [Jobs] WHERE [Job_ID] = ?" 
        InsertCommand="INSERT INTO [Jobs] ([Incident_ID], [Job_ID], [Description], [Job Completed?], [Date Created], [Date Resolved], [Assigned Team]) VALUES (?, ?, ?, ?, ?, ?, ?)" 
        SelectCommand="SELECT Incident_ID, Job_ID, Description, [Job Completed?], [Date Created], [Assigned Team], [Date Resolved] FROM Jobs WHERE (Job_ID = ?)" 
        UpdateCommand="UPDATE Jobs SET [Job Completed?] = ?, [Date Resolved] = ? WHERE (Job_ID = ?)">
        <DeleteParameters>
            <asp:Parameter Name="Job_ID" Type="Int32" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="Incident_ID" Type="Int32" />
            <asp:Parameter Name="Job_ID" Type="Int32" />
            <asp:Parameter Name="Description" Type="String" />
            <asp:Parameter Name="column1" Type="Boolean" />
            <asp:Parameter Name="Date_Created" Type="DateTime" />
            <asp:Parameter Name="Date_Resolved" Type="DateTime" />
            <asp:Parameter Name="Assigned_Team" Type="Int32" />
        </InsertParameters>
        <SelectParameters>
            <asp:QueryStringParameter DefaultValue="1" Name="Job_ID" 
                QueryStringField="job_id" Type="Int32" />
        </SelectParameters>
        <UpdateParameters>
            <asp:Parameter Name="Job Completed?" Type="Boolean" />
            <asp:Parameter Name="Date Resolved" Type="DateTime" />
            <asp:Parameter Name="Job_ID" Type="Int32" />
        </UpdateParameters>
    </asp:AccessDataSource>
</asp:Content>

